<template>
  <div id="addaddress">
    <van-nav-bar
        left-text="新增地址"
        right-text="..."
        left-arrow
        @click-left="onClickLeft"
    />
    <van-form @submit="onSubmit">
        <van-field
        v-model="name"
        name="name"
        placeholder="name"
        :rules="[{ required: true, message: '请填写联系人' }]"
        />
        <van-field
        v-model="phone"
        name="phone"
        placeholder="phone"
        :rules="[{ required: true, message: '请填写联系方式' }]"
        />
        <van-field
        v-model="address"
        name="address"
        placeholder="address"
        :rules="[{ required: true, message: '请填写联系地址' }]"
        />
        <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit">保存并使用</van-button>
        </div>
    </van-form>


  </div>
</template>

<script>
import { mapActions } from 'vuex';
export default {
  data() {
    return {
            name: '',
            phone: '',
            address: '',
    };
  },
  methods: {
    ...mapActions('address',['request_add_address']),
    onSubmit(values) {
      this.request_add_address(values);
      this.$router.go(-1);
    },
    onClickLeft() {
        this.$router.go(-1);
    },
  },
};
</script>

<style>

</style>